#include <linux/init.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/platform_device.h>

struct resource *mysource;

int mydriver_probr(struct platform_device *dev){
		printk("This is mydriver_probr\n");
		/*获取flag为内存IORESOURCE_MEM类型，索引值为0的资源*/
		mysource = platform_get_resource(dev,IORESOURCE_MEM,0);

		printk("The MEM is %x\n",mysource->start);
		return 0;
	}

int mydriver_remove(struct platform_device *dev){
		printk("This is mydriver_remove\n");
		return 0;
}


struct platform_driver platform_driver_test = {
	.probe = mydriver_probr,
	.remove = mydriver_remove,
	.driver = {
		.name = "my_platform_test",
		.owner = THIS_MODULE,
	},
};

 
/* 驱动入口函数 */
static int  platform_init(void) {
	printk("This is platform_init\n");
	/*加载platform*/
	platform_driver_register(&platform_driver_test);
	return 0;
	
}
 
/* 驱动出口函数 */
static void  platform_exit(void)	{
	printk("This is platform_exit\n");

	platform_driver_unregister(&platform_driver_test);

}
module_init(platform_init);	/*指定设备驱动入口函数*/
module_exit(platform_exit);	/*指定设备驱动出口函数*/
MODULE_LICENSE("GPL");
